<?php
$hide = $_REQUEST["hide"];
$conn = mysqli_connect("127.0.0.1", "root", "", "coffee");
mysqli_query($conn, "SET NAMES utf8");
if ($hide == "getproduct") {
    $sql = "SELECT * FROM product";
    $rs = mysqli_query($conn, $sql);
	$arr = [];
	while (($row = mysqli_fetch_assoc($rs)) != null) {
		array_push($arr, $row);
	}
	echo JSON_encode($arr);
}else if ($hide == "getteam") {
    $sql = "SELECT * FROM role";
    $rs = mysqli_query($conn, $sql);
	$arr = [];
	while (($row = mysqli_fetch_assoc($rs)) != null) {
		array_push($arr, $row);
	}
	echo JSON_encode($arr);
}else if ($hide == "getnews") {
    $sql = "SELECT * FROM news";
    $rs = mysqli_query($conn, $sql);
	$arr = [];
	while (($row = mysqli_fetch_assoc($rs)) != null) {
		array_push($arr, $row);
	}
	echo JSON_encode($arr);
}else if ($hide == "gethistory") {
    $sql = "SELECT * FROM history";
    $rs = mysqli_query($conn, $sql);
	$arr = [];
	while (($row = mysqli_fetch_assoc($rs)) != null) {
		array_push($arr, $row);
	}
	echo JSON_encode($arr);
}
mysqli_close($conn);
